<!DOCTYPE html>
<html>
<head>
<title>Control Panel</title>
<script type="text/javascript" src="scripts/jquery-1.11.0.min.js"></script>
<script src="scripts/scripts.js" type="text/javascript"></script>
<link rel="stylesheet" href="styles/styles.css" type="text/css" />
<script type="text/javascript" src="scripts/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php 
require_once'functions.php';
require_once'config.php';

$username = $_SESSION['username'];
$getStudentByUN = getStudentByUN($username);
$studentID = $_SESSION['studentID'];
//$attempt = $_POST['attempt'];
//$_SESSION['attempt'] = $attempt;
$getAttempts = getAttempts($studentID);

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
//$num = $_POST['num'];
//$currentQuestion = $num;
//$score = $_SESSION['score']; 
//$_SESSION['attempt'] = $_POST['attempt'];
//$attempt = $_SESSION['attempt'];
$getAttempts = getAttempts($studentID);
}

$attempt = $_SESSION['attempt'];	
?>
<header>Learner Centred Design Formative Assessment<span class="loggedIn">Logged in as:<?php echo ucfirst($_SESSION['firstName']);?>&nbsp;&nbsp;<a href="logout.php">Logout</a></span></header>
<nav>
<?php include 'nav.php' ?>
</nav>
<div id="container" class="one-edge-shadow">
  <div id="mainContent">
    <h2>Welcome, <?php echo ucfirst ($_SESSION['firstName']) ?>.</h2>
    <h3>Notes for the tutor</h3>
<p class="emphasis">When you take the assessment you must take it in one uninterrupted go to avoid reporting issues relating from unfinished attempts which are unsupported in this application at present. In reality I would like for the learner to be able to log out between attempts and also to be able to resume mid-test should they need to. Unfortunately, these features were beyond my capability.</p>
<p class="emphasis">I recommend that you take the assessment, view results then have another go using the button provided to allow for comparison. Following this you will be safe to log out and back in to view and compare results and take more attempts if you wish.</p> 
<p>On your first attempt, you will receive feedback on the correctness of your answer. In subsequent attempts the correct answer will be displayed.</p>
 <?php if ($_SESSION['attempt'] == 1) {  ?>
  <form method='post' action="postquiz.php" id="assessment">
    <input type='submit' id='take' name='take' value='Take assessment'  class='btn'>
	<input type="hidden" name="num" value="<?php echo $num?>">
    <input type="hidden" name="score" value="<?php echo $score ?>">
    <input type="hidden" name="attempt" value="<?php echo $_SESSION['attempt'] ?>">
</form> 

  <?php  } if ($_SESSION['attempt'] > 1) {  ?>
  <form method='post' action="postquiz.php" id="assessment">
    <input type='submit' id='take' name='retake' value='Retake assessment'  class='btn'>
   <input type="hidden" name="num" value="<?php echo $num?>">
    <input type="hidden" name="score" value="<?php echo $score ?>">
    <input type="hidden" name="attempt" value="<?php echo ($attempt + 1) ?>">
    	</form>    
    <form method='post' action="report.php" id="report">
    <input type='submit' id='goReport' name='goReport' value='View feedback and compare attempts' class='btn'>
    <input type="hidden" name="num" value="<?php echo $num?>">
    <input type="hidden" name="score" value="<?php echo $score ?>">
    <input type="hidden" name="attempt" value="<?php echo $_SESSION['attempt'] + 1 ?>">
    </form>

 <?php } ?>

<!--   
<p class='smiling'>Attempt:<?php echo $attempt ?></p>
<p class='smiling'>Score:<?php echo $score ?></p>
<p class='smiling'>Num:<?php echo $num ?></p>
<p class='smiling'>Current Question:<?php echo $currentQuestion ?></p>
<p class='smiling'>firstName:<?php echo $_SESSION['firstName']?></p>
<p class='smiling'>score:<?php echo $_SESSION['score'];?></p>
<p class='smiling'>username:<?php echo $_SESSION['username'];?></p>
<p class='smiling'>id:<?php echo $_SESSION['studentID'];?></p>
<p class='smiling'>attempt:<?php echo $_SESSION['attempt'];?>
-->

</div>
</div>
</body>
</html>
